import request from '@/utils/request'

/**
 * 查询模型列表
 * @param {*} query
 */
export function getModelList(query) {
  return request({
    url: '/flow/act/model/s',
    method: 'post',
    params: {
      pageSize: query.pageSize,
      pageNum: query.pageNum
    },
    data: {
      ...query
    }
  })
}

/**
 * 根据Id查询模型
 * @param {*} modelId
 */
export function getById(modelId) {
  return request({
    url: '/flow/act/model/' + modelId,
    method: 'get'
  })
}

/**
 * 保存模型
 */
export function save(data) {
  if (data.id===undefined || data.id==='') {
    return request({
      url: '/flow/act/model/create',
      method: 'post',
      data
    })
  }
  else {
    return request({
      url: '/flow/act/model/edit',
      method: 'post',
      data
    })
  }
}

/**
 * 删除模型
 * @param {*} modelId
 */
/*export function del(modelId) {
  return request({
    url: '/activiti/model/' + modelId,
    method: 'delete'
  })
}*/
export function del(modelId) {
  return request({
    url: `/flow/act/model/${modelId}/delete`,
    method: 'get'
  })
}

/**
 * 部署模型
 * @param {*} modelId
 */
export function deployment(modelId) {
  return request({
    url: `/flow/act/model/${modelId}/deployment`,
    method: 'get'
  })
}


export function getModelXml(modelId) {
  return request({
    url: '/flow/act/model/'+modelId+'/xml',
    method: 'get'
  })
}


export function saveXml(modelId, data) {
  return request({
    url: '/flow/act/model/'+modelId+'/xml/save',
    method: 'post',
    data
  })
}



